/**
 * 
 */
package cz.cuni.mff.abacs.burglar.logics.objects.agents;


/**
 * 
 * 
 * @author abacs
 *
 */
public class BurglarGoal implements GoalBase {
	
	
	/** Room ID
	 * Changeable property. */
	protected int _aimId = -1;
	
	
	/** 
	 * Changeable property. */
	protected int _itemIdToCollect = -1;
	
	
	// -------------------------------------------------------------------------
	// constructors:
	
	
	/**
	 * 
	 * @param aimId
	 * @param itemIdToCollect
	 */
	public BurglarGoal(int aimId, int itemIdToCollect) {
		this._aimId = aimId;
		this._itemIdToCollect = itemIdToCollect;
	}
	
	
	/**
	 * 
	 * @param other
	 * @param itemIdToCollect
	 */
	protected BurglarGoal(BurglarGoal other) {
		this._aimId = other._aimId;
		this._itemIdToCollect = other._itemIdToCollect;
	}
	
	
	// -------------------------------------------------------------------------
	
	
	/**
	 * 
	 * @param roomId
	 */
	public void setAimId(int roomId) {
		this._aimId = roomId;
	}	
	
	
	/**
	 * 
	 * @return
	 */
	public int getAimId() {
		return this._aimId;
	}
	
	
	/**
	 * 
	 * @param itemId
	 */
	public void setItemIdToCollect(int itemId) {
		this._itemIdToCollect = itemId;
	}
	
	
	/**
	 * 
	 * @return
	 */
	public int getItemIdToCollect() {
		return this._itemIdToCollect;
	}
	
	
	// -------------------------------------------------------------------------
	
	
	@Override
	public boolean isSatisfied(BaseAgent agent) {
		
		System.out.println(
				"is satisfied: " + (this._aimId == agent.getRoomId()) + 
				"  (" + agent.getRoomId() + ") " +
				(agent.hasItem(this._itemIdToCollect))
		);
		
		if(agent.isInRoom(this._aimId) && agent.hasItem(_itemIdToCollect))
			return true;
		return false;
	}
	
	
	// -------------------------------------------------------------------------
	
	
	@Override
	public void copyChangeables(GoalBase other) {
		this._aimId = ((BurglarGoal)other)._aimId;
		this._itemIdToCollect = ((BurglarGoal)other)._itemIdToCollect;
	}
	
	
}
